{template header}
<script type="text/javascript">
function dologin(){
	if(get_value("username") == ''){
		alert('帐号不能为空');
		get_id("username").focus();
		return false;
	}
	if(get_value("username") == ''){
		alert('密码不能为空');
		get_id("password").focus();
		return false;
	}
}
telok=1;
usernameok=1;
repasswdok=1;
emailok=1;
function check_tel(){
    var tel=get_id("tel");
    var ra = /^((\(\d{3}\))|(\d{3}\-))?13\d{9}|15\d{9}$/;
    if( tel.value.length!=11||!tel.value.match(ra) ){ 
    	get_id("teltip").innerHTML = "×手机号格式不正确!";
        telok=0; 
    }else{
    	var url = g_site_url + 'index.php?user/ajaxtel/'+tel.value+'/';
		send_request(url,showtel,'/');	
    	//get_id("teltip").innerHTML ="√";
    }
}
function showtel(){
	if(http_request.responseText == 1){
		get_id("teltip").innerHTML = "×手机号已经存在!";
		telok=0;
	}
	else if(http_request.responseText == 2){
		get_id("teltip").innerHTML = "×手机号格式不正确!";
		telok=0;
	}else{
		get_id("teltip").innerHTML ="<font color='green'>√</font>";
		telok=1;
	}
}
function check_email(){
    var email=get_id("email");
    reg = new RegExp('^[a-zA-Z0-9]+@[a-zA-Z0-9]+.[a-z][a-z.]{2,8}$');
    if(reg.test(email.value)){
    	emstr = email.value.split('.');
    	var url = g_site_url + 'index.php?user/ajaxemail/'+emstr[0]+'/'+emstr[1]+'/';
		send_request(url,showemail,'/');
    	//get_id("emailtip").innerHTML = "√";
    }else{
    	get_id("emailtip").innerHTML = "×邮件格式不正确!";
        emailok=0;
    }
}
function showemail(){
	if(http_request.responseText == 1){
		get_id("emailtip").innerHTML = "×邮件已经存在!";
		emailok=0;
	}
	else if(http_request.responseText == 2){
		get_id("emailtip").innerHTML = "×邮件不正确!";
		emailok=0;
	}else{
		get_id("emailtip").innerHTML ="<font color='green'>√</font>";
		emailok=1;
	}
}
function check_username(){
    var user=get_id("usernames"); 
    var url = g_site_url + 'index.php?user/ajaxusername/'+user.value+'/';
	send_request(url,showuser,'/');	
}
function showuser(){
	if(http_request.responseText == 1){
		get_id("usernametip").innerHTML = "×用户名已经存在!";
		usernameok=0;
	}
	else if(http_request.responseText == 2){
		get_id("usernametip").innerHTML = "×用户名格式不正确!";
		usernameok=0;
	}else{
		get_id("usernametip").innerHTML ="<font color='green'>√</font>";
		usernameok=1;
	}
}
    function check_passwd(){
        var passwd=get_id("passwords").value;
        if( passwd.length <6|| passwd.length>16){
        	get_id("passwordtip").innerHTML = "×密码最少6个字符！";
        }else{
            get_id("passwordtip").innerHTML = "<font color='green'>OK</font>";
        }
    }

    function check_repasswd(){
        var repassword=get_id("repasswords").value;
        if( repassword.length <6|| repassword.length>16){
            get_id("repasswordtip").innerHTML = "密码最少6个字符！";
            repasswdok=0;
        }else{
            if(get_id("passwords").value==get_id("repasswords").value){
                get_id("repasswordtip").innerHTML = "<font color='green'>OK</font>";
            }else{
                get_id("repasswordtip").innerHTML = "两次密码输入不一致！";
                repasswdok=0;
            }
        }
    }



    function docheck(){
        if(telok && usernameok && repasswdok && emailok ){
        	if(get_id("city").options[get_id("city").selectedIndex].value != ''){
        		return true;
        	}else{
        		alert("请选择城市");
        		return false;
        	}
        }
    }
</script>
<!-- main -->

<div class="login_main">
	<div class="login_left"><form name="loginform"  action="{url user/login}" method="post" onsubmit="return dologin();">
    	<ul>
        	<li><img src="img/welcome.gif" width="190" height="40" alt="登录" /></li>
            <li>帐户名(手机号或Email)：</li>
            <li><INPUT style="WIDTH: 242px" tabIndex=1 maxLength=32 id="username" name="username"></li>      
            <li>密码：</li>
            <li><INPUT style="WIDTH: 242px" tabIndex=2 type=password  id="password" name="password"></li>
             <!--{if $setting['code_login']}-->
             <li>验证码：</li>
              <li><input type="text" size="10"  maxlength="4"  id="code" name="code" onblur="check_code()" />&nbsp;<img id="verifycode" onclick="javascript:updatecode();" src="{url user/code}"/>
                                <span><a href="javascript:updatecode();">看不清，换一个</a></span>
                                <span id="codetip" class="font_gray2"></span></li>
                        <!--{/if}-->
            <li><input type="checkbox" checked value="1" id="cookietime" name="cookietime">&nbsp;下次自动登录  <a class="red" href="{url user/getpass}">忘记密码了?</a>   </li> 
            <li><input  class="logsub" name="submit" type="submit" value="&nbsp;"  /></li>    
        </ul>
        </form>

    </div>
    <div class="login_rihgt"><form name="reg" name="registform"   action="{url user/register}" method="post" onsubmit="return docheck();">
    	<ul>
        	<li><img src="img/newuser.gif" width="190" height="40" alt="登录" /></li>
            <li>手机号码：<span id="teltip"></span></li>
            <li><input type="text" size="35" maxlength="15" id="tel" name="tel" onblur="check_tel()" ></li>      
            <li>Email地址：<span id="emailtip"></span></li>
            <li><input type="text" size="35" maxlength="100" id="email" name="email" onblur="check_email()" ></li>
			<li>用户昵称：<span id="usernametip"></span></li>
            <li><input type="text" size="35"  maxlength="18" id="usernames" name="usernames" onblur="check_username()"></li>
            <li>创建密码：<span id="passwordtip"></span></li> 
            <li><input type="password" size="35" maxlength="16"  id="passwords" name="passwords"  onblur="check_passwd()">
            </li>
            <li>密码确认：<span id="repasswordtip"></span></li> 
            <li>
                 <input type="password" size="35" maxlength="16" id="repasswords" name="repasswords"  onblur="check_repasswd()">
            </li>
            <li>常住城市：<span id="usernametip"></span></li>
            <li><SELECT style="WIDTH: 90px" name=area id="area" onchange="get_city2();"><option value="">-选择省-</option>{loop $areacn $areaid $area}<option value="{$areaid}">{$area[name]}</option>{/loop}</SELECT> 
            <span id="city22"><SELECT style="WIDTH: 90px" name=city id="city"><option value="">-选择地区-</option></SELECT></span>
			</li>
            <li>注册类型：</li>
            <li><INPUT class=checkboxid id=treg1 type=radio value=7  name=gid style="border:0px;" checked>个人会员 <INPUT class=checkboxid id=treg2  type=radio value=9  name=gid style="border:0px;" >批发商 <INPUT class=checkboxid id=treg3  type=radio value=8  name=gid style="border:0px;">分销商</li>  
            
             <li></li>  
            <li><input  class="logzhu"name="search" type="submit" value="&nbsp;"  /></li>       
        </ul>
		</form>
    </div>
</div>
<!-- main  end-->
{template footer}